{include file='public/_header' /}

<link rel="stylesheet" href="/static/lib/editormd/css/editormd.min.css">

<!-- Main Container -->
<div class="main-container container-fluid">
	<!-- Page Container -->
	<div class="page-container">

		<!-- Page Sidebar -->
		{include file='public/_left' /}
        <!-- /Page Sidebar -->
            <!-- Page Content -->
            <div class="page-content">
                <!-- Page Breadcrumb -->
                <div class="page-breadcrumbs">
                    <ul class="breadcrumb">
                        <li>
                            <i class="fa fa-home"></i>&nbsp;文章管理
                        </li>
                        <li>文章添加</li>
                    </ul>
                </div>
                <!-- /Page Breadcrumb -->
                <!-- Page Body -->
                <div class="page-body">
                	<div class="row">
                		<div class="col-xs-12">
                			<div class="widget radius-bordered">
                				<div class="widget-header bordered-bottom bordered-themeprimary">
                					<span class="widget-caption">文章添加</span>
                				</div>
                				<div class="widget-body">
                					<form id="form" class="form-horizontal">
                						<div class="form-group">
                							<label for="title" class="control-label col-sm-1">文章标题</label>
                							<div class="col-sm-6">
                								<input type="text" class="form-control" id="title" name="title" placeholder="文章标题" />
                							</div>
                						</div>
                						<div class="form-group">
                							<label for="cateid" class="control-label col-sm-1">所属导航</label>
                							<div class="col-sm-6">
                								<select id="cateid" name="cateid" class="form-control">
                									<option value="">请选择</option>

													{volist name='cates' id='cate'}
                										<option value="{$cate.id}">{$cate.catename}</option>
													{/volist}

                								</select>
                							</div>
                						</div>
										<div class="form-group">
											<label for="flag" class="control-label col-sm-1">原创标记</label>
											<div class="col-sm-6">
												<input type="text" class="form-control" id="flag" name="flag" placeholder="原创标记" />
											</div>
										</div>
										<div class="form-group">
											<label for="tags" class="control-label col-sm-1">文章标签</label>
											<div class="col-sm-6">
												<input type="text" class="form-control" id="tags" name="tags" placeholder="文章标签" />
												<p class="help-block">多个标签用 | 分割</p>
											</div>
										</div>

										<div class="form-group">
											<div class="checkbox col-sm-offset-1 col-sm-6">
												<label>
													<input type="checkbox" name="is_top" value="">
													<span class="text">是否推荐</span>
												</label>
											</div>
										</div>
										<div class="form-group">
											<label for="desc" class="control-label col-sm-1">文章概述</label>
											<div class="col-sm-6">
												<textarea name="desc" id="desc" cols="105" rows="3" class=""></textarea>
											</div>
										</div>
										<div class="form-group">
											<label for="content" class="control-label col-sm-1" style="margin-bottom: 5px;">文章内容</label>
											<div id="md-content" style="z-index: 999;">
												<textarea id="content" name="content" placeholder="文章内容" style="display:none;"></textarea>
											</div>

										</div>
                						<div class="form-group">
                							<div class="col-sm-offset-1 col-sm-1">
                								<button class="btn btn-primary" id="articleAdd">添加</button>
                							</div>
                						</div>
                					</form>
                				</div>
                			</div>
                		</div>
                	</div>
                </div>
                <!-- /Page Body -->
            </div>
            <!-- /Page Content -->

        </div>
        <!-- /Page Container -->
        <!-- Main Container -->

    </div>

{include file='public/_js' /}

<script src="/static/lib/editormd/editormd.min.js"></script>

<script>
	// 初始化markdown编辑器----------------------
	var contentEditor;
	$(function() {
		contentEditor = editormd("md-content", {
			width: "90%",
			height: 600,
			syncScrolling: "single",
			path: "/static/lib/editormd/lib/"
		});
	});
	//-------------------------------------------

	// 提交添加
	$('#articleAdd').click(function () {
		$.ajax({
			url: '',
			type: 'post',
			dataType: 'json',
			data: $('#form').serialize(),
			success: function (data) {
				if (data.code == 1){
					layer.msg('文章添加成功', {
						icon: 6,
						time: 500
					}, function () {
						location.href = data.url;
					});
				}else {
					layer.open({
						title: '文章添加失败',
						content: data.msg,
						icon: 5,
						anim: 6
					});
				}

			}
		});

		return false;
	});

</script>

</body>
<!--  /Body -->
</html>
